import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";
import { globalIgnores } from "eslint/config";

export default tseslint.config([
	globalIgnores(["dist"]),
	{
		files: ["**/*.{ts,tsx}"],
		extends: [
			js.configs.recommended,
			tseslint.configs.recommended,
			reactHooks.configs["recommended-latest"],
			reactRefresh.configs.vite,
		],
		languageOptions: {
			ecmaVersion: 2020,
			globals: globals.browser,
		},
		rules: {
			"@typescript-eslint/no-explicit-any": "off", // 允许 any
			"react-refresh/only-export-components": "off", // 需要文件有明确的导出
			"prefer-const": "off", // 允许 const
			"no-unused-expressions": "off", // 允许未使用的表达式
			"@typescript-eslint/no-unused-expressions": "off", // 允许未使用的表达式 (TypeScript 版本)
			"no-unused-vars": [
				"error",
				{
					varsIgnorePattern: "^_",
					argsIgnorePattern: "^_|args",
				},
			], // 允许未使用的以下划线开头的变量和参数，以及 args 参数
			"@typescript-eslint/no-unused-vars": [
				"error",
				{
					varsIgnorePattern: "^_",
					argsIgnorePattern: "^_|args",
				},
			], // 允许未使用的以下划线开头的变量和参数，以及 args 参数 (TypeScript 版本)
		},
	},
]);
